#ifndef D20BASEMODEL_H
#define D20BASEMODEL_H



#include "d20models_global.h"
#include <ItemModel.h>


#include <QMap>



class D20MODELSSHARED_EXPORT D20BaseModel : public ItemModel
{
    Q_OBJECT

public:

    D20BaseModel(QObject *parent = 0);

    virtual Qt::ItemFlags flags(const QModelIndex &index) const;

    virtual void setRootItem(RootItem *root);
    virtual void initialize();

    // group handling functions
    void addGroup(const int& group, const QString& name);
    QList<QString> groupNames() const
    {
        return m_groups.values();
    }

    QList<int> groups() const
    {
        return m_groups.keys();
    }

    QString groupName(const int& group) const;
    int group(const QString& name) const;

    QModelIndex groupIndex(const int& group) const;
    QModelIndex groupIndex(const QString& name) const;

    // item handling functions
//    int addItem(const int& group, const QString& name);
//    int addSubItem(const QString& itemName, const QString& newName);

    bool removeItem(const QString& name);
    bool removeItem(const int& group, const int& item);
    bool removeItem(const int& group, const QString& name);

    QModelIndexList itemIndexes(const int& group) const;
    QModelIndexList itemIndexes(const QString& name) const;

    QModelIndex itemIndex(const int& group, const QString& name) const;


protected:

    QMap<int, QString> m_groups;


};

#endif // D20BASEMODEL_H
